# Maintainer: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=gmic
pkgver=3.0.0
pkgrel=1
pkgdesc="GREYC's Magic for Image Computing"
url="https://gmic.eu/"
arch="all"
license="CECILL-2.1"
makedepends="
	cmake
	curl-dev
	eigen-dev
	fftw-dev
	graphicsmagick-dev
	openexr-dev
	tiff-dev
	"
depends="ncurses"
subpackages="
	$pkgname-bash-completion
	$pkgname-doc
	$pkgname-dev
	$pkgname-libs
	"
source="https://gmic.eu/files/source/gmic_$pkgver.tar.gz"
options="!check" # No test suite

# Enable opencv support when possible
# opencv-dev is not available on s390x and ppc64le
case "$CARCH" in
	s390x|ppc64le)
		_enable_opencv=OFF ;;
	*)
		makedepends="$makedepends opencv-dev"
		_enable_opencv=ON ;;
esac

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi

	cmake -B build \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DENABLE_DYNAMIC_LINKING=ON \
		-DBUILD_LIB_STATIC=OFF \
		-DENABLE_OPENCV=$_enable_opencv \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
89353d16d6304e322400c93bafb50f7557df93c933ed2994f33a17d877e4e12ec511a355b38058680f356bccab5aa84b607fab225354c19d4b8ab3e64424c87c  gmic_3.0.0.tar.gz
"
